@extends('backend::modal')
@section('title',$page_title)
@push('styles')
    <link href="{{asset(config('view.plugin').'/layui/layui_ext/cascader/cascader.css')}}" rel="stylesheet">
@endpush
@section('content')
    @if($info)
        @component('backend::component.form.form')
        @slot('page_title') {{$page_title}} @endslot
        @slot('formId') add-category @endslot
        @slot('action') {{route('b_ShopCategory_update',['id'=>$info->id])}} @endslot

        @component('backend::component.form.form-group')
            @slot('title') 分类名称 @endslot
            @component('backend::component.form.input')
                @slot('name') name @endslot
                @slot('value') {{$info->name}} @endslot
            @endcomponent
        @endcomponent

        @component('backend::component.form.form-group')
            @slot('title') 分类名称简写 @endslot
            @component('backend::component.form.input')
                @slot('name') name_mobile @endslot
                @slot('value') {{$info->name_mobile}} @endslot
            @endcomponent
            @slot('remark')为方便手机显示,请尽量保持再四字以内 @endslot
        @endcomponent

        @component('backend::component.form.form-group')
            @slot('title') 分类描述 @endslot
            @component('backend::component.form.input')
                @slot('name') description @endslot
                @slot('value') {{$info->description}} @endslot
            @endcomponent
        @endcomponent

        @component('backend::component.form.form-group')
            @slot('title') 分类图标 @endslot
            @component('backend::component.upload.upload_img',['imgList'=>[$info->image=>$info->image]])
                @slot('name') image @endslot
                @slot('title') 上传图片 @endslot
                @slot('img_num')1 @endslot
                @slot('group') shop @endslot
            @endcomponent
        @endcomponent

        @component('backend::component.form.form-group')
            @slot('title') 父级分类 @endslot
            <div class="layui-input-block">
                <input type="text" id="action_parent" data-parents='{{$parent_info}}' data-default="{{$info->parent_ids}}"
                       class="form-control" readonly="readonly"/>
                <input type="hidden" id="parent-value" name="parents"   value="{{$info->parent_ids}}">
            </div>
        @endcomponent

        @component('backend::component.form.form-group')
            @slot('title') 排序 @endslot
            @component('backend::component.form.input')
                @slot('name') sort @endslot
                @slot('value') 1000 @endslot
            @endcomponent
        @endcomponent
        @component('backend::component.form.form-group')
            @slot('title') 热销分类 @endslot
            <div>
                @foreach(['0'=>'否','1'=>'是'] as $value=>$title)
                    @component('backend::component.radio')
                        @slot('title') {{$title}} @endslot
                        @slot('name') is_hot @endslot
                        @slot('value') {{$value}} @endslot
                        @if($value == $info->is_host)
                            @slot('checked') checked @endslot
                        @endif
                    @endcomponent
                @endforeach
            </div>
        @endcomponent
        @component('backend::component.form.form-group')
            @slot('title') 状态 @endslot
            <div>
                @foreach(['0'=>'禁用','1'=>'启用'] as $value=>$title)
                    @component('backend::component.radio')
                        @slot('title') {{$title}} @endslot
                        @slot('name') status @endslot
                        @slot('value') {{$value}} @endslot
                        @if($value == $info->status)
                            @slot('checked') checked @endslot
                        @endif
                    @endcomponent
                @endforeach
            </div>
        @endcomponent
        @slot('buttons')
            @component('backend::component.form.button')
                @slot('title') 提交 @endslot
                @slot('params') {"formId":"#add-category"} @endslot
                @slot('class') btn-min-width ajax-form @endslot
            @endcomponent
            @component('backend::component.form.button')
                @slot('title') 重置 @endslot
                @slot('type') reset @endslot
                @slot('color') danger @endslot
                @slot('class') btn-min-width @endslot
            @endcomponent
        @endslot
    @endcomponent
    @else
        @component('backend::public.empty_page')
            @slot('info') 分类信息不存在 @endslot
        @endcomponent
    @endif
@endsection
@include('backend::component.upload.upload_js')
@push('scripts')
    <script>
        layui.use(['jquery','layer','cascader'], function(){
            var $ = layui.jquery;
            var cascader = layui.cascader;
            init();

            function init(){
                selectParentAction();
            }

            function selectParentAction() {
                var data = $('#action_parent').data('parents');
                var defaultVal = $('#action_parent').data('default').toString();
                if(defaultVal&&defaultVal.indexOf(",") != -1){
                    var defaultValArr = defaultVal.split(",")
                }else{
                    var defaultValArr = [defaultVal?defaultVal:0];
                }
                cascader({
                    elem: "#action_parent",
                    data: data,
                    triggerType: "change",
                    // showLastLevels:true,
                    value: defaultValArr,
                    changeOnSelect:true,
                    success:function (valData) {
                        $('#parent-value').val(valData);
                    }
                });
            }
        });
    </script>
@endpush